using ASP;
using HoWave.Web;
using HoWave.Web.Shop.Member;
using System;
using System.Collections;
using System.Data;
using System.Web.Profile;
using System.Web.SessionState;
using System.Web.UI.WebControls;
public class Member_Shop_Saler_Message : Member, IRequiresSessionState
{
	protected RadioButtonList CheckSalerMessage;
	protected DropDownList DropDownList1;
	protected GridView GridView1;
	protected Button DelSalerMessage;
	private int mType;
	private string usertype = string.Empty;
	protected DefaultProfile Profile
	{
		get
		{
			return (DefaultProfile)this.Context.Profile;
		}
	}
	protected global_asax ApplicationInstance
	{
		get
		{
			return (global_asax)this.Context.ApplicationInstance;
		}
	}
	protected void Page_Load(object sender, EventArgs e)
	{
		if (!base.IsPostBack)
		{
			this.BindList();
			ShopConfigBll shopConfigBll = new ShopConfigBll();
			DataTable config = shopConfigBll.GetConfig();
			if (!config.Rows[0]["ShowShop"].ToString().Equals("1"))
			{
				this.CheckSalerMessage.Items.RemoveAt(1);
			}
			config.Dispose();
		}
		this.GridView1.PageIndexChanging += new GridViewPageEventHandler(this.GridView1_PageIndexChanging);
	}
	protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
	{
		this.GridView1.PageIndex = e.NewPageIndex;
		this.BindList();
	}
	protected void CheckSalerMessage_SelChang(object sender, EventArgs e)
	{
		this.BindList();
	}
	protected void DropDownList1_SelChang(object sender, EventArgs e)
	{
		this.BindList();
	}
	protected void BindList()
	{
		this.QuestString();
		Shop_Message shop_Message = new Shop_Message(this.conn);
		DataTable messageByTypeUserIDSalerID = shop_Message.GetMessageByTypeUserIDSalerID(this.mType, base.user.UserID, this.usertype);
		this.GridView1.DataSource = messageByTypeUserIDSalerID;
		this.GridView1.DataBind();
	}
	protected void QuestString()
	{
		this.mType = Convert.ToInt32(this.CheckSalerMessage.SelectedValue);
		this.usertype = "saler";
	}
	protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
	{
		if (e.Row.RowType == DataControlRowType.DataRow)
		{
			bool flag = false;
			bool flag2 = false;
			if (base.shopconfig["ShowQQ"].ToString() == "1")
			{
				flag = true;
			}
			if (base.shopconfig["ShowWW"].ToString() == "1")
			{
				flag2 = true;
			}
			Image image = (Image)e.Row.FindControl("QQImage");
			if (flag && image.ImageUrl != "")
			{
				image.ImageUrl = "http://wpa.qq.com/pa?p=1:" + image.ImageUrl + ":4";
			}
			else
			{
				image.Visible = false;
			}
			Image image2 = (Image)e.Row.FindControl("TaobaoImage");
			if (flag2 && image2.ImageUrl != "")
			{
				image2.ImageUrl = "http://amos1.taobao.com/online.ww?v=2&amp&uid=" + base.Server.UrlEncode(image2.ImageUrl) + "&s=2";
				HyperLink hyperLink = (HyperLink)e.Row.FindControl("TaobaoLink");
				hyperLink.NavigateUrl = "http://amos1.taobao.com/msg.ww?v=2&amp&Uid=" + base.Server.UrlEncode(hyperLink.NavigateUrl) + "&s=2";
			}
			else
			{
				image2.Visible = false;
			}
			HyperLink hyperLink2 = (HyperLink)e.Row.FindControl("Status");
			if (hyperLink2.Text == "False")
			{
				hyperLink2.Text = "未回复";
			}
			else
			{
				hyperLink2.Text = "已回复";
			}
		}
	}
	protected void DelSalerMessage_Click(object sender, EventArgs e)
	{
		ArrayList arrayList = new ArrayList();
		for (int i = 0; i < this.GridView1.Rows.Count; i++)
		{
			CheckBox checkBox = (CheckBox)this.GridView1.Rows[i].FindControl("MessageSelect");
			HiddenField hiddenField = (HiddenField)this.GridView1.Rows[i].FindControl("HiddenID");
			if (checkBox.Checked)
			{
				arrayList.Add(hiddenField.Value);
			}
		}
		for (int j = 0; j < arrayList.Count; j++)
		{
			int num = this.conn.Execute("delete HLShop_Message where M_ID=" + int.Parse(arrayList[j].ToString()));
		}
		this.BindList();
	}
}
